﻿<%@ WebHandler Language="C#" Class="SynchronizeUser" %>

using System;
using System.Web;

/// <summary>
/// 用户和单位信息同步
/// </summary>
public class SynchronizeUser : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        String versionID = context.Request["versionId"];
        
         string strReturn = synchronous(versionID);
         context.Response.Write(strReturn);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

    /// <summary>
    /// 用户和单位信息同步
    /// </summary>
    /// <param name="versionId">版本号</param>
    /// <returns></returns>
    public string synchronous(String versionId)
    {
//        string strXml = @"<?xml version='1.0' encoding='UTF-8'?>
//<operationXml><trans><versionId>4028fb8350ac14b60150ac14b6b50000</versionId><transType>ADD_USER</transType><transXml><id>4028fb83507dde4301507de234750008</id><userId>SUPERADMIN</userId><appId>4028fb83507dd41701507dd614ec0003</appId><display>0</display><username>wangqq</username><pwd>123123123</pwd></transXml></trans></operationXml>";
        
        string strReturn = "0";
        try
        {
            ChBusiness.InterfaceClass.UserTbOperation cuiTemp = new ChBusiness.InterfaceClass.UserTbOperation();
            SynchronizeClient SC = new SynchronizeClient(System.Configuration.ConfigurationManager.AppSettings["userSynAddress"]);
            string strXml = SC.getTransXmlByVersionId("get_syn", versionId);
            //Common.Log.LogManage.addLogErr(versionId, strXml);
            cuiTemp.AnalyseXml(strXml, "综合服务门户");
            strReturn = "1";
        }
        catch(Exception ex)
        {
            Common.Log.LogManage.addLogErr(versionId, ex.Message);
        }
        return strReturn;
    }


}